<#assign c = JspTaglibs["http://java.sun.com/jsp/jstl/core"] >
<#assign fmt = JspTaglibs["http://java.sun.com/jsp/jstl/fmt"] >
<#assign sp = JspTaglibs["http://www.springframework.org/tags"] >

<table class="resultTable" *ngIf="inputDates"><caption style="font-size:23px;"><@sp.message code="data.input.date.list"/></caption>
	<thead>
	<tr>
	<!-- 	<th><@sp.message code="data.input.date.str"/></th>
		<th><@sp.message code="data.input.title"/></th> -->
		<th><@sp.message code="data.input.date"/></th>
		<th><@sp.message code="data.input.effective.time"/></th>
		<th><@sp.message code="data.input.active.status"/></th>
		<th><@sp.message code="data.input.status"/></th>
		<th><@sp.message code="data.input.create.time"/></th>
		<th><@sp.message code="data.input.last.update.time"/></th>
		<th><@sp.message code="data.input.update.user"/></th>
	</tr>
	</thead>
	<tbody>
	<tr *ngFor="let inputDate of inputDates" (click)="selectDataInputDate(inputDate)" [class.selected]="inputDate.isSelected"  >
		<!-- <td>{{inputDate.dataDate}}</td>
		<td>{{inputDate.dueDate | date:'yyyy-MM-dd'}}</td> -->
		<!-- <td (click)="editDataInputDate(inputDate)"><a href="javascript:void">{{inputDate.dueDate | date:'MM月dd日'}}</a></td> -->
		<td (click)="editDataInputDate(inputDate)"><a href="javascript:void(0);">{{formatDate(inputDate.dueDate ,'MM月dd日')}}</a></td>
		<td>{{formatDate(inputDate.effectFromDate,'yyyy-MM-dd')}} - {{ inputDate.effectToDate ? formatDate(inputDate.effectToDate ,'yyyy-MM-dd') : "<@sp.message code='data.input.effective.present'/>"}}</td>
		<!-- <td>{{inputDate.isActive ? "<@sp.message code='data.input.active.true'/>" : "<@sp.message code='data.input.active.false'/>" }}</td> -->
		
		<td>{{resolveMessage("activeState_" + inputDate.activeState)}}</td>
		
		
<!--		<td (click)="showHistory(inputDate)"><a href="javascript:void">{{resolveMessage("status_" + inputDate.state)}}</a></td>  -->
		<td >{{resolveMessage("status_" + inputDate.state)}}</td>
		<td>{{formatDate(inputDate.createTime,'yyyy-MM-dd')}}</td>
		<td>{{formatDate(inputDate.lastUpdateTime,'yyyy-MM-dd')}}</td>
		<td>{{inputDate.lastUpdateUser}}</td>
		
	</tr>
	</tbody>
</table >
<button *ngIf="isInputer" (click)="newDataInputDate()" ><@sp.message code="txt.add"/></button>

<p-dialog header="<@sp.message code='date.input.title'/>" [(visible)]="isAddDatainputDate" modal="modal" [width]="600">
<div  *ngIf="inputDateSelected" style="height:300px;">

<table style="width:100%;border-collapse:separate; border-spacing:0px 4px;">
	 
	 <tr *ngIf="(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')">
		<th style="width:70px;  color: #000"><@sp.message code="data.input.date" /></th>
		<td >
		<input type="text" [(ngModel)]="inputDateSelected.dataDate" readonly/>
	</tr> 
	<tr *ngIf="!(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')">
		<th style="color: #000;"><@sp.message code="data.input.date" /></th>   
		<td class="disableYear">
			<p-calendar     readonlyInput="true"  
			  [(ngModel)]="inputDateSelected.dueDate" dateFormat="mm-dd" [locale]="calLang" ></p-calendar>
			
		</td>
	</tr>
	
<!-- 	<tr  *ngIf="(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')">
		<th><@sp.message code="data.input.effective.time" /></th>
		<td>
			<input type="text"  readonly  [ngModel]="inputDateSelected.effectFromDate | date:'yyyy-MM-dd' " />
			
		</td>
	</tr>
	<tr *ngIf="!(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')">
		<th><@sp.message code="data.input.effective.time" /></th>
		<td>
			<p-calendar  [disabled]="(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')" 
			 [(ngModel)]="inputDateSelected.effectFromDate" dateFormat="yy-mm-dd" [locale]="calLang"></p-calendar>
			
		</td>
	</tr> -->
	
<!-- 	<tr>
		<th style="width:70px;"><@sp.message code="data.input.active.status" /></th>
		<td >
			<select class="form-control"  required [(ngModel)]="inputDateSelected.isActive"  
			 [disabled]="(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')"  >
				<option  value="true"><@sp.message code="data.input.active.true" /></option>
				<option  value="false"><@sp.message code="data.input.active.false" /></option>
			</select>
			
		</td>
	</tr> -->
	
	<!-- <tr>
		<th style="width:70px; color: #000"><@sp.message code="data.input.active.status" /></th>
		<td >
			<select class="form-control"  required [(ngModel)]="inputDateSelected.activeState"  
			 [disabled]="true"  >
			
				<option  value="forEnable">待启用</option>
				<option  value="enabled">已启用</option>
				<option  value="forDisable">待停用</option>
				<option  value="disabled">已停用</option>
			</select>
		 	<input type="text" [(ngModel)]="inputDateSelected.activeState" readonly/> 
		</td>
	</tr> -->
	
	<!-- <tr>
		<th style="color: #000;"><@sp.message code="data.input.file" /></th>
		<td>
			<span *ngIf="!(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')">
				<iisp-file-upload [fileUploadInfo]="fileUploadInfo">Uploader here...</iisp-file-upload>
			</span>
			<span style="display:block;width:200px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" *ngFor="let f of this.fileUploadInfo.uploadedFiles">{{f.substring(f.lastIndexOf("/") + 1)}}</span>
			<a style="display:block;width:200px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;color: blue;" *ngIf="inputDateSelected.fileUrl" href="${fileDownloadRoot}{{inputDateSelected.fileUrl}}" target="_blank">{{inputDateSelected.fileUrl.substring(inputDateSelected.fileUrl.lastIndexOf("/") + 1)}}</a>
		</td>
	</tr> -->
	
	<tr >
		<th style="color: #000;"><@sp.message code="data.input.approver" /></th>
		<td>
		<!-- 	<input [disabled]="inputDateSelected.state != 'NEW' && inputDateSelected.state != 'SAVED' && (inputDateSelected.state =='FOR_APPROVE'&&!isApprover)"  
			 type="text" [(ngModel)]="inputDateSelected.approver" required/>
			  -->
			  <!--   [disabled]="inputDateSelected.state != 'NEW' && inputDateSelected.state != 'SAVED' && (inputDateSelected.state =='FOR_APPROVE'&&!isApprover)"  -->
			 <ng-container *ngIf="!isApprover && (inputDateSelected.state=='NEW'||inputDateSelected.state=='SAVED'||inputDateSelected.state=='REJECT')">
				 <select class="form-control" required [(ngModel)]="inputDateSelected.approver" (ngModelChange)="onSelectApprover(inputDateSelected.approver)">
					<option *ngFor="let p of approvers" [value]="p.code">{{p.name}}</option>
				 </select>
			 </ng-container>
			 <ng-container *ngIf="(isApprover || inputDateSelected.state=='FOR_APPROVE'||inputDateSelected.state=='APPROVED')">
				 <select disabled="true" class="form-control" required>
					<option value="{{inputDateSelected.approver}}">{{inputDateSelected.approverName}}</option>
				 </select>
			 </ng-container>
		</td>
		
	</tr>
	
		<tr   *ngIf="isApprover && inputDateSelected.state=='FOR_APPROVE' && isCurApprover" >
		<th style="color: #000;"><@sp.message code="data.input.transfer" /></th>
		<td>
			 <select    
			    class="form-control"        required [(ngModel)]="approverNew">
				<option *ngFor="let p of approvers" [value]="p.code">{{p.name}}</option>
			</select>
			 
			 
		</td>
	</tr>
	
	<tr *ngIf="isApprover && inputDateSelected.state=='FOR_APPROVE' && isCurApprover">
		<th style="color: #000;"><@sp.message code="data.input.approve.comment" /></th>
		
		<td >
			<textarea  rows="5" cols="60"  [(ngModel)]="inputDateSelected.approverComment"  [readonly]="inputDateSelected.state!='FOR_APPROVE' || !isApprover"></textarea>
		</td>
		
	</tr>

	<tr><td colspan="2" style="text-align:right;padding:20px;padding-right:30px;">
		<span *ngIf="!isApprover && (inputDateSelected.state=='NEW')">
		  <button (click)="addDataInputDate('TO_APPROVE')" ><@sp.message code="data.input.date.TO_APPROVE" /></button>
		  <button (click)="addDataInputDate('SAVE')" ><@sp.message code="data.input.date.SAVE" /> </button>
		  <button (click)="addDataInputDate('DELETE')"><@sp.message code="data.input.date.DELETE" /> </button>
		</span>
		<span *ngIf="!isApprover && (inputDateSelected.state=='SAVED'||inputDateSelected.state=='REJECTED')">
		  <button (click)="saveDataInputDate('TO_APPROVE')"><@sp.message code="data.input.date.TO_APPROVE" /></button>
		  <button (click)="saveDataInputDate('SAVE')" ><@sp.message code="data.input.date.SAVE" /> </button>
		  <button (click)="saveDataInputDate('DELETE')" ><@sp.message code="data.input.date.DELETE" /></button>
		</span>
		<span *ngIf="isApprover && inputDateSelected.state=='FOR_APPROVE' && isCurApprover">
		  <button (click)="transferTask()"><@sp.message code="data.input.date.transfer" /> </button>
		  <button (click)="saveDataInputDate('APPROVE')"><@sp.message code="data.input.date.APPROVE" /> </button>
		  <button (click)="saveDataInputDate('REJECT')"><@sp.message code="data.input.date.REJECT" /></button>
		 
		</span>
		<span *ngIf=" inputDateSelected.state=='APPROVED'">
		   <button *ngIf="!isApprover&&inputDateSelected.activeState=='enabled'" (click)="disableDataInputDate('CHOOSE_APPROVER')"><@sp.message code="data.input.date.disabled.apply" /></button>
		   <button *ngIf="isApprover&&inputDateSelected.activeState=='forDisable'" (click)="disableDataInputDate('APPROVE')">
		   		<@sp.message code="data.input.date.disabled.approved" />
		   	</button>
		   <button *ngIf="isApprover&&inputDateSelected.activeState=='forDisable'" (click)="disableDataInputDate('REJECT')">
		   		<@sp.message code="data.input.date.disabled.rejected" />
		   	</button>	   	
		</span>
	</td></tr>
</table>

</div>
</p-dialog>




<p-dialog header="<@sp.message code='data.input.date.choose.approvers'/>" [(visible)]="isChooseApprover" modal="modal" [width]="600">
	<div  *ngIf="inputDateSelected">
		<table style="width:100%;border-collapse:separate; border-spacing:0px 4px;">
			<tr>
					<th ><@sp.message code="data.input.approver" /></th>
					<td>
						 <select 
						    class="form-control" required [(ngModel)]="inputDateSelected.approver">
							<option *ngFor="let p of approvers" [value]="p.code">{{p.name}}</option>
						</select>
					</td>
			</tr>
			
			<tr>
				<td colspan="2" style="text-align:right;padding:20px;padding-right:30px;">
					<span >
					   <button  (click)="disableDataInputDate('TO_APPROVE')"><@sp.message code="data.input.date.TO_APPROVE" /></button>
		  	 			<button  (click)="disableDataInputDate('CANCEL')"><@sp.message code="data.input.date.cancel" /></button>
					</span>
				</td>
			</tr>
		</table>
	</div>
</p-dialog>			


<p-dialog header="提示" [(visible)]="isCheckDueDateTitle" modal="modal" [width]="600">
    <div style="text-align:center;">
	 	<p style="margin:30px 0;"><@sp.message code="data.input.dueDateTitle" /></p>
	 	<input type="button" value="<@sp.message code="data.input.dueDateClose" />" (click)="checkDueDateClose()">
	</div>
</p-dialog>


<!-- <p-dialog header="任务流转明细" [(visible)]="isShowHistory" modal="modal" [width]="600">
<act-hist-list [procInstId]="inputDateSelected.processInstId" ></act-hist-list>
</p-dialog> -->

<p-dialog header="任务流转明细" [(visible)]="isActHistShow" modal="modal"  [width]="600" >

<act-hist-list [procInstId]="inputDateSelected.processInstId" ></act-hist-list>
</p-dialog>




<message-box [isRunning]="isRunning()"></message-box>